package com.myiam.idm.meta.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.ManyToAny;
import org.hibernate.validator.constraints.Length;


@Entity
@Table(name="META_ROLE")
public class MmRole extends MmBase implements Serializable {

	/**
	 * 
	 */
	@Transient
	private static final long serialVersionUID = -7003478375676546029L;

	@Id
	@GeneratedValue()
    @NotNull
	private long id;
	
	@Column
	private String name;
	
	@Column
	private String type;

	
	@OneToMany(mappedBy="parent",targetEntity=com.myiam.idm.meta.model.MmRole.class)
	private List<MmRole> children;
	
	//@Column
	@ManyToOne	
	private MmRole parent;


	public void addChild(MmRole child) {
		if (children == null) {
			children = new ArrayList<MmRole>();
		}
		children.add(child);
	}
	
 	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public List<MmRole> getChildren() {
		return children;
	}

	public void setChildren(List<MmRole> children) {
		this.children = children;
	}

	public MmRole getParent() {
		return parent;
	}

	public void setParent(MmRole parent) {
		this.parent = parent;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	
	
}
